//
//  YZCommunityMineVC.m
//  VET
//
//  Created by YZ on 2018/7/18.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "YZCommunityMineVC.h"
#import "YZCommunityWebViewModel.h"

@interface YZCommunityMineVC ()

@property (nonatomic, strong) YZCommunityWebViewModel *viewModel;

@end

@implementation YZCommunityMineVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view
    self.view.backgroundColor = kColorWithHex(0xFFFFFF);
    [self setWebViewFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - YZ_BOTTOM_MARGIN)];
    [self setProgressViewFrame:CGRectMake(0, kStatusBarHeight, kScreenWidth, 2)];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]}];
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO];
}

#pragma  mark -- override

- (void)customUserContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
{
}

- (void)customWebView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
    [self.viewModel doActionWithMessage:message currentController:self];
    completionHandler();
}

- (void)customWwebView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    decisionHandler(WKNavigationActionPolicyAllow);
}

#pragma mark -- setters && getters

- (YZCommunityWebViewModel *)viewModel
{
    if (!_viewModel) {
        _viewModel = [[YZCommunityWebViewModel alloc] init];
    }
    return _viewModel;
}
@end
